#include<iostream>
#include<memory>



template<class _Ty>
class auto_ptr{
    public:
        auto_ptr(_Ty *_P=0): _Owns(_P!=0), _Ptr(_P){}
        ~auto_ptr(){if(_Owns) delete _Ptr;}
    private:
        bool _Owns;
        _Ty *_Ptr;  //指向资源的指针
};

int main(){
    int *p = new int(10);
    auto_ptr<int> Po(p);

    std::cout<< *p << std::endl;
    return 0;
}